<?php

namespace app\admin\controller;

use think\Controller;
use think\Request;
use think\Db;
use app\admin\model\Feedback;//问题反馈

class Problem extends Auth
{
    //我的反馈
    public function feedback(Request $request)
    {
        $res = $request->param();
        $res['lang'] = $this->lang;
        if ($request->isAjax() && $request->isPost()) {
            $feedbacks = new Feedback();
            $getfeedbacks = $feedbacks->getfeedback($res);
            echo json_encode(array('getfeedbacks' => $getfeedbacks['data'], 'size' => $getfeedbacks['count']));
        } elseif ($request->isGet()) {
            return view('feedback/myfeedback');
        }
    }

    //删除反馈
    public function feedbackdel(Request $request)
    {
        $feedbacks = new Feedback();
        $res = $request->param();
        if ($request->isAjax() && $request->isPost()) {
            $delfeedback = $feedbacks->delfeedback($res);
            echo json_encode($delfeedback);
        }
    }

    //问题反馈详情
    public function myfeedback(Request $request)
    {
        $feedbacks = new Feedback();
        $res = $request->param();
        $res['lang'] = $this->lang;
        $feedbacks = new Feedback();
        if ($request->isAjax() && $request->isPost() && isset($res['getmyfeedback'])) {
            $getfeeddetail = $feedbacks->getfeedbackdetail($res);
            echo json_encode($getfeeddetail);
        } elseif ($request->isAjax() && $request->isPost() && isset($res['savemyfeedback'])) {
            $savedetail = $feedbacks->savedetail($res);
            echo json_encode($savedetail);
        }
    }

    //反馈列表
    public function feedindex(Request $request)
    {
        $res = $request->param();
        $res['lang'] = $this->lang;
        if ($request->isAjax() && $request->isPost()) {
            $feedbacks = new Feedback();
            $getfeedbacks = $feedbacks->getfeedback($res);
            echo json_encode(array('getfeedbacks' => $getfeedbacks['data'], 'size' => $getfeedbacks['count']));
        } elseif ($request->isGet()) {
            return view('feedback/feedbacks');
        }
    }

    //问题详情的修复
    public function repairfeed(Request $request)
    {
        $res = $request->param();
        $feedbacks = new Feedback();
        if ($request->isAjax() && $request->isPost()) {
            $data=$feedbacks->feedbackrepair($res);
            echo json_encode($data);

        }
    }

    //问题反馈详情
    public function feedbackdetail(Request $request)
    {
        $feedbacks = new Feedback();
        $res = $request->param();
        $res['lang'] = $this->lang;
        $feedbacks = new Feedback();
        if ($request->isAjax() && $request->isPost() && isset($res['getfeedback'])) {
            $getfeeddetail = $feedbacks->getfeedbackdetail($res);
            echo json_encode($getfeeddetail);
        } elseif ($request->isAjax() && $request->isPost() && isset($res['savefeedback'])) {
            $savedetail = $feedbacks->savedetail($res);
            echo json_encode($savedetail);
        }
    }
}
